from django.db import models


# Create exercise models here.


class ExerciseInfo(models.Model):

    id = models.AutoField(primary_key=True)

    question = models.CharField('题干', max_length=255, unique=True)
    option_a = models.CharField('选项A', max_length=50, null=True)
    option_b = models.CharField('选项B', max_length=50, null=True)
    option_c = models.CharField('选项C', max_length=50, null=True)
    option_d = models.CharField('选项D', max_length=50, null=True)
    option_e = models.CharField('选项E', max_length=50, null=True)
    answer = models.CharField('答案', max_length=50, null=True)
    description = models.CharField('答案描述', max_length=256, null=True)
    collection = models.BooleanField('收藏', default=False)
    category = models.CharField('题目分类', max_length=30, null=True)

    correct_count = models.IntegerField('做对的次数', default=0)
    total_count = models.IntegerField('做这道题总计多少次', default=0)
    pub_time = models.DateTimeField('题目发布日期', auto_now_add=True)

    class Meta:
        db_table = 't_exercise'
        ordering = ['id']

    def __str__(self):
        return self.question
